<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="mall/advert/include::header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>修改</h5>
					</div>
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="form">
							<input type="hidden" id="id" name="id" th:value="${brokerage.id}">
							<div class="form-group">
								<label class="col-sm-3 control-label">升级数量:</label>
								<div class="col-sm-8">
									<input id="count" name="count" class="form-control" type="text" th:value="${brokerage.count}">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">188电子名片佣金:</label>
								<div class="col-sm-8">
									<input id="brokerage1" name="brokerage1" class="form-control" type="text" th:value="${brokerage.brokerage1}">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">188团队管理佣金:</label>
								<div class="col-sm-8">
									<input id="brokerage2" name="brokerage2" class="form-control" type="text" th:value="${brokerage.brokerage2}">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">888电子名片佣金:</label>
								<div class="col-sm-8">
									<input id="brokerage3" name="brokerage3" class="form-control" type="text" th:value="${brokerage.brokerage3}">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">888团队管理佣金:</label>
								<div class="col-sm-8">
									<input id="brokerage4" name="brokerage4" class="form-control" type="text" th:value="${brokerage.brokerage4}">
								</div>
							</div>

							<div class="form-group text-center">
								<div class="col-sm-8 col-sm-offset-2">
									<button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>提交</button>
									<div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="mall/advert/include::footer"></div>
	<script type="text/javascript">
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}

		$().ready(function() {
			validateRule();
		});

		$.validator.setDefaults({
			submitHandler : function() {
				save();
			}
		});

		function save() {
			$.ajax({
				cache : true,
				type : "POST",
				url : "/businesscard/manage/editBrokerage",
				data : $('#form').serialize(),// 你的formid
				async : false,

				success : function(data) {
					if (data.code == 0) {
						parent.layer.msg("操作成功");
						parent.reLoad();
						var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
						parent.layer.close(index);
					} else {
						if (data.msg) {
							parent.layer.alert(data.msg)
						}else {
							window.location.href = "/";
						}
					}

				}
			});
		}

		function validateRule() {
			var icon = "<i class='fa fa-times-circle'></i> ";
			$("#form").validate({
				rules : {
					count : {
						required : true
					}
				},
				messages : {
					count : {
						required : icon + "升级数量"
					}
				}
			})
		}

		function onThumbBlur() {
			var url = $.trim($('#thumb').val());
			if (url) {
				if (url.indexOf("http") >= 0 || url.indexOf("https") >= 0) {
					$('#categoryAddthumbImg').attr('src', url);
				}else {
					var prefix = "http://pic.jinzhishenghuo.com";
					$('#categoryAddthumbImg').attr('src', prefix + url);
				}
			}
		}

		/**
		 * 加载图片URL
		 * @param inputId
		 * @param imgId
		 * @param url
		 */
		function loadImgUrl(inputId, imgId, url) {
			$('#'+inputId +'').val(url);
			$('#'+imgId +'').attr('src', url);
		}

		/**
		 * 选择图片页面
		 * @param inputId
		 * @param imgId
		 */
		function onSelectImgBtnClick(inputId, imgId) {
			layer.open({
				id:'selectImg',
				type : 2,
				title : '选择图片',
				maxmin : true,
				shadeClose : false,
				area : [ '90%', '90%' ],
				content : '/platform/config/selectImg/' + inputId +"/"+ imgId // iframe的url
			});
		}

		/**
		 * 选择视频页面
		 * @param inputId
		 * @param imgId
		 */
		function onSelectVideoBtnClick(inputId, imgId) {
			layer.open({
				id:'selectImg',
				type : 2,
				title : '选择视频',
				maxmin : true,
				shadeClose : false,
				area : [ '90%', '90%' ],
				content : '/platform/config/selectVideo/' + inputId +"/"+ imgId // iframe的url
			});
		}
	</script>
</body>

</html>
